package com.cloud.pole.recharge.controller;

import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.cloud.pole.common.constant.CommonConstants;
import com.cloud.pole.common.exception.BaseException;
import com.cloud.pole.common.exception.ParamException;
import com.cloud.pole.common.msg.ApiRestResponse;
import com.cloud.pole.recharge.model.BankRecvFeeOutRsp;
import com.cloud.pole.recharge.model.CancelTradeRsp;
import com.cloud.pole.recharge.model.PreOrderForOuterRsp;
import com.cloud.pole.recharge.model.ProductChangeOutRsp;
import com.cloud.pole.recharge.model.QryPayResultRsp;
import com.cloud.pole.recharge.model.QueryDiscntOutResp;
import com.cloud.pole.recharge.model.QueryOutNumInfoRsp;
import com.cloud.pole.recharge.model.SelTempOccupyResOutRsp;
import com.cloud.pole.recharge.model.UnifiedPayDetailRsp;
import com.cloud.pole.recharge.service.RechargeService;
import lombok.extern.slf4j.Slf4j;

@Controller
@Slf4j
@RequestMapping("/recharge/front")
public class MobileRechargeController {

	@Autowired
	private RechargeService rechargeService;

	/**
	 * 4.1外部渠道精准营销推荐
	 * 
	 * @param msisdn
	 * @return
	 */
	@ResponseBody
	@GetMapping("/triggerExt")
	public ApiRestResponse<Boolean> triggerExt(@RequestParam(defaultValue = "") String msisdn) {
		try {
			ParamException.err(StringUtils.isBlank(msisdn), "msisdn不能为空");
			rechargeService.triggerExt(msisdn);
			return ApiRestResponse.success(CommonConstants.STATUS_OK_MESSAGE, Boolean.TRUE);
		} catch (BaseException e) {
			return ApiRestResponse.fail(e.getStatus(), e.getMessage(), null);
		} catch (Exception e) {
			log.error(CommonConstants.STATUS_ERROR_MESSAGE + "{}", e.getMessage(), e);
			return ApiRestResponse.fail(CommonConstants.STATUS_ERROR_MESSAGE, null);
		}
	}

	/**
	 * 4.2产品元素推荐
	 * 
	 * @return
	 */
	@ResponseBody
	@GetMapping("/queryDiscntOut")
	public ApiRestResponse<QueryDiscntOutResp> queryDiscntOut(@RequestParam(defaultValue = "") String serialNumber) {
		try {
			ParamException.err(StringUtils.isBlank(serialNumber), "serialNumber不能为空");
			return ApiRestResponse.success(CommonConstants.STATUS_OK_MESSAGE,
					rechargeService.queryDiscntOut(serialNumber));
		} catch (BaseException e) {
			return ApiRestResponse.fail(e.getStatus(), e.getMessage(), null);
		} catch (Exception e) {
			log.error(CommonConstants.STATUS_ERROR_MESSAGE + "{}", e.getMessage(), e);
			return ApiRestResponse.fail(CommonConstants.STATUS_ERROR_MESSAGE, null);
		}
	}

	/**
	 * 4.3短信验证码下发
	 * 
	 * @return
	 */
	@ResponseBody
	@GetMapping("/sendSmsVerifyCodeOut")
	public ApiRestResponse<Boolean> sendSmsVerifyCodeOut(@RequestParam(defaultValue = "") String serialNumber,
			@RequestParam(defaultValue = "110") String tradeTypeCode) {
		try {
			ParamException.err(StringUtils.isBlank(serialNumber), "serialNumber不能为空");
			ParamException.err(StringUtils.isBlank(tradeTypeCode), "tradeTypeCode不能为空");
			return ApiRestResponse.success(CommonConstants.STATUS_OK_MESSAGE,
					rechargeService.sendSmsVerifyCodeOut(serialNumber, tradeTypeCode));
		} catch (BaseException e) {
			return ApiRestResponse.fail(e.getStatus(), e.getMessage(), null);
		} catch (Exception e) {
			log.error(CommonConstants.STATUS_ERROR_MESSAGE + "{}", e.getMessage(), e);
			return ApiRestResponse.fail(CommonConstants.STATUS_ERROR_MESSAGE, null);
		}
	}

	/**
	 * 4.4短信验证码校验
	 * 
	 * @return
	 */
	@ResponseBody
	@GetMapping("/checkSmsVerifyCodeOut")
	public ApiRestResponse<Boolean> checkSmsVerifyCodeOut(@RequestParam(defaultValue = "") String serialNumber,
			@RequestParam(defaultValue = "110") String tradeTypeCode,
			@RequestParam(defaultValue = "") String verifyCode) {
		try {
			ParamException.err(StringUtils.isBlank(serialNumber), "serialNumber不能为空");
			ParamException.err(StringUtils.isBlank(tradeTypeCode), "tradeTypeCode不能为空");
			ParamException.err(StringUtils.isBlank(verifyCode), "verifyCode不能为空");

			return ApiRestResponse.success(CommonConstants.STATUS_OK_MESSAGE,
					rechargeService.checkSmsVerifyCodeOut(serialNumber, tradeTypeCode, verifyCode));
		} catch (BaseException e) {
			return ApiRestResponse.fail(e.getStatus(), e.getMessage(), null);
		} catch (Exception e) {
			log.error(CommonConstants.STATUS_ERROR_MESSAGE + "{}", e.getMessage(), e);
			return ApiRestResponse.fail(CommonConstants.STATUS_ERROR_MESSAGE, null);
		}
	}

	/**
	 * 4.5产品/优惠受理
	 * 
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/productChangeOut", method = RequestMethod.GET)
	public ApiRestResponse<ProductChangeOutRsp> productChangeOut(@RequestParam(defaultValue = "") String serialNumber,
			@RequestParam(defaultValue = "") String discntCode, @RequestParam(defaultValue = "") String productId,
			@RequestParam(defaultValue = "") String smsCode) {
		try {
			ParamException.err(StringUtils.isBlank(serialNumber), "serialNumber不能为空");
			ParamException.err(StringUtils.isBlank(discntCode), "discntCode不能为空");
			ParamException.err(StringUtils.isBlank(smsCode), "smsCode不能为空");

			return ApiRestResponse.success(CommonConstants.STATUS_OK_MESSAGE,
					rechargeService.productChangeOut(serialNumber, discntCode, productId, smsCode));
		} catch (BaseException e) {
			return ApiRestResponse.fail(e.getStatus(), e.getMessage(), null);
		} catch (Exception e) {
			log.error(CommonConstants.STATUS_ERROR_MESSAGE + "{}", e.getMessage(), e);
			return ApiRestResponse.fail(CommonConstants.STATUS_ERROR_MESSAGE, null);
		}
	}

	/**
	 * 4.6存费活动受理
	 * 
	 * @param serialNumber      服务号码
	 * @param smsCode           短信验证码
	 * @param writeoffMode      销帐方式 '0'-按用户
	 * @param recoverTag        复机标志 '0'-不复机
	 * @param xFpayFee          收费金额
	 * @param chargeSourceCode  费用来源编码
	 * @param payFeeModeCode    收费方式
	 * @param carrierCode       载体类型
	 * @param removeTag         销号标志 0－正常
	 * @param channelTradeId    渠道缴费业务流水
	 * @param channelAcceptTime 渠道缴费时间
	 * @param channelId         渠道编码
	 * @param tradeTypeCode     业务类型
	 * @param productId         产品编码
	 * @param packageId         包编码
	 * @param paraCode1         预留字段1
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/bankRecvFeeOut", method = RequestMethod.GET)
	public ApiRestResponse<BankRecvFeeOutRsp> bankRecvFeeOut(
			@RequestParam(defaultValue = "13973110012") String serialNumber,
			@RequestParam(defaultValue = "264453") String smsCode,
			@RequestParam(defaultValue = "0") String writeoffMode, @RequestParam(defaultValue = "0") String recoverTag,
			@RequestParam(defaultValue = "5000") String xFpayFee,
			@RequestParam(defaultValue = "37") String chargeSourceCode,
			@RequestParam(defaultValue = "0") String payFeeModeCode,
			@RequestParam(defaultValue = "0") String carrierCode, @RequestParam(defaultValue = "0") String removeTag,
			@RequestParam(defaultValue = "1234567") String channelTradeId,
			@RequestParam(defaultValue = "2020-03-30 17:18:45") String channelAcceptTime,
			@RequestParam(defaultValue = "WXLS") String channelId,
			@RequestParam(defaultValue = "240") String tradeTypeCode,
			@RequestParam(defaultValue = "99916036") String productId,
			@RequestParam(defaultValue = "99967194") String packageId,
			@RequestParam(defaultValue = "HF") String paraCode1,
			@RequestParam(defaultValue = "1000") String trdeFee,
			@RequestParam(defaultValue = "3107040400984318") String acctId,
			@RequestParam(defaultValue = "3") String paymentId

			) {
		try {
			ParamException.err(StringUtils.isBlank(serialNumber), "serialNumber不能为空");
			ParamException.err(StringUtils.isBlank(smsCode), "smsCode不能为空");

			Map<String, Object> map = new HashMap<>();
			map.put("serialNumber", serialNumber);
			map.put("smsCode", smsCode);
			map.put("writeoffMode", writeoffMode);
			map.put("recoverTag", recoverTag);
			map.put("xFpayFee", xFpayFee);
			map.put("chargeSourceCode", chargeSourceCode);
			map.put("payFeeModeCode", payFeeModeCode);
			map.put("carrierCode", carrierCode);
			map.put("removeTag", removeTag);
			map.put("channelTradeId", channelTradeId);
			map.put("channelAcceptTime", channelAcceptTime);
			map.put("channelId", channelId);
			map.put("tradeTypeCode", tradeTypeCode);
			map.put("productId", productId);
			map.put("packageId", packageId);
			map.put("paraCode1", paraCode1);
				
			/**
			 * 测试增加参数：2021-03-02
			 */
			map.put("trdeFee", trdeFee);
			map.put("acctId", acctId);
			map.put("paymentId", paymentId);

			return ApiRestResponse.success(CommonConstants.STATUS_OK_MESSAGE, rechargeService.bankRecvFeeOut(map));
		} catch (BaseException e) {
			return ApiRestResponse.fail(e.getStatus(), e.getMessage(), null);
		} catch (Exception e) {
			log.error(CommonConstants.STATUS_ERROR_MESSAGE + "{}", e.getMessage(), e);
			return ApiRestResponse.fail(CommonConstants.STATUS_ERROR_MESSAGE, null);
		}
	}

	/**
	 * 4.7获取支付流水号
	 * 
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/buildSeq", method = RequestMethod.GET)
	public ApiRestResponse<String> buildSeq() {
		try {
			return ApiRestResponse.success(CommonConstants.STATUS_OK_MESSAGE, rechargeService.buildSeq());
		} catch (BaseException e) {
			return ApiRestResponse.fail(e.getStatus(), e.getMessage(), null);
		} catch (Exception e) {
			log.error(CommonConstants.STATUS_ERROR_MESSAGE + "{}", e.getMessage(), e);
			return ApiRestResponse.fail(CommonConstants.STATUS_ERROR_MESSAGE, null);
		}
	}

	/**
	 * 4.8获取支付链接
	 * 
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/unifiedPayDetail", method = RequestMethod.GET)
	public ApiRestResponse<UnifiedPayDetailRsp> unifiedPayDetail(@RequestParam(defaultValue = "") String peerOrderId,
			@RequestParam(defaultValue = "") String crmOrderId, @RequestParam(defaultValue = "") String orderFee,
			@RequestParam(defaultValue = "") String serialNumber, @RequestParam(defaultValue = "") String orderDesc,
			@RequestParam(defaultValue = "") String merchantId, @RequestParam(defaultValue = "") String opId,
			@RequestParam(defaultValue = "") String orgId, @RequestParam(defaultValue = "") String countyId,
			@RequestParam(defaultValue = "") String regionId, @RequestParam(defaultValue = "") String busiType,
			@RequestParam(defaultValue = "") String payType, @RequestParam(defaultValue = "") String payWay,
			@RequestParam(defaultValue = "") String reqChannel, @RequestParam(defaultValue = "") String returnUrl) {
		try {
			Map<String, Object> map = new HashMap<>();
			map.put("peerOrderId", peerOrderId);
			map.put("crmOrderId", crmOrderId);
			map.put("orderFee", orderFee);
			map.put("serialNumber", serialNumber);
			map.put("orderDesc", orderDesc);
			map.put("merchantId", merchantId);
			map.put("opId", opId);
			map.put("orgId", orgId);
			map.put("countyId", countyId);
			map.put("regionId", regionId);
			map.put("busiType", busiType);
			map.put("payType", payType);
			map.put("payWay", payWay);
			map.put("reqChannel", reqChannel);
			map.put("returnUrl", returnUrl);
			return ApiRestResponse.success(CommonConstants.STATUS_OK_MESSAGE, rechargeService.unifiedPayDetail(map));
		} catch (BaseException e) {
			return ApiRestResponse.fail(e.getStatus(), e.getMessage(), null);
		} catch (Exception e) {
			log.error(CommonConstants.STATUS_ERROR_MESSAGE + "{}", e.getMessage(), e);
			return ApiRestResponse.fail(CommonConstants.STATUS_ERROR_MESSAGE, null);
		}
	}

	// 4.10未支付订单取消接口
	@ResponseBody
	@RequestMapping(value = "/cancelTrade", method = RequestMethod.GET)
	public ApiRestResponse<CancelTradeRsp> cancelTrade(
			@RequestParam(defaultValue = "") String orderId,
			@RequestParam(defaultValue = "") String routeEparchyCode, @RequestParam(defaultValue = "") String amount,
			@RequestParam(defaultValue = "") String payMoneyCode, @RequestParam(defaultValue = "") String peerOrderId) {
		try {
			Map<String, Object> map = new HashMap<>();
			map.put("orderId", orderId);
			map.put("routeEparchyCode", routeEparchyCode);
			map.put("amount", amount);
			map.put("payMoneyCode", payMoneyCode);
			map.put("peerOrderId", peerOrderId);

			return ApiRestResponse.success(CommonConstants.STATUS_OK_MESSAGE, rechargeService.cancelTrade(map));
		} catch (BaseException e) {
			return ApiRestResponse.fail(e.getStatus(), e.getMessage(), null);
		} catch (Exception e) {
			log.error(CommonConstants.STATUS_ERROR_MESSAGE + "{}", e.getMessage(), e);
			return ApiRestResponse.fail(CommonConstants.STATUS_ERROR_MESSAGE, null);
		}
	}

	// 4.11支付预受理订单归档
	@ResponseBody
	@RequestMapping(value = "/paySuccFunc", method = RequestMethod.GET)
	public ApiRestResponse<String> paySuccFunc(
			@RequestParam(defaultValue = "13973110012") String serialNumber,
			@RequestParam(defaultValue = "") String tradeId,
			@RequestParam(defaultValue = "") String routeEparchyCode, 
			@RequestParam(defaultValue = "") String amount,
			@RequestParam(defaultValue = "") String payMoneyCode, 
			@RequestParam(defaultValue = "") String peerOrderId) {
		try {
			Map<String, Object> map = new HashMap<>();
			map.put("serialNumber", serialNumber);
			map.put("tradeId", tradeId);
			map.put("routeEparchyCode", routeEparchyCode);
			map.put("amount", amount);
			map.put("payMoneyCode", payMoneyCode);
			map.put("peerOrderId", peerOrderId);

			return ApiRestResponse.success(CommonConstants.STATUS_OK_MESSAGE, rechargeService.paySuccFunc(map));
		} catch (BaseException e) {
			return ApiRestResponse.fail(e.getStatus(), e.getMessage(), null);
		} catch (Exception e) {
			log.error(CommonConstants.STATUS_ERROR_MESSAGE + "{}", e.getMessage(), e);
			return ApiRestResponse.fail(CommonConstants.STATUS_ERROR_MESSAGE, null);
		}
	}

	// 4.12支付结果查询
	@ResponseBody
	@RequestMapping(value = "/qryPayResult", method = RequestMethod.GET)
	public ApiRestResponse<QryPayResultRsp> qryPayResult(@RequestParam(defaultValue = "") String peerOrderId,
			@RequestParam(defaultValue = "") String createDate, @RequestParam(defaultValue = "") String checkDate) {
		try {
			Map<String, Object> map = new HashMap<>();
			map.put("peerOrderId", peerOrderId);
			map.put("createDate", createDate);
			map.put("checkDate", checkDate);
			return ApiRestResponse.success(CommonConstants.STATUS_OK_MESSAGE, rechargeService.qryPayResult(map));
		} catch (BaseException e) {
			return ApiRestResponse.fail(e.getStatus(), e.getMessage(), null);
		} catch (Exception e) {
			log.error(CommonConstants.STATUS_ERROR_MESSAGE + "{}", e.getMessage(), e);
			return ApiRestResponse.fail(CommonConstants.STATUS_ERROR_MESSAGE, null);
		}
	}

	// 4.13号卡预约订单同步
	@ResponseBody
	@RequestMapping(value = "/preOrderForOuter", method = RequestMethod.GET)
	public ApiRestResponse<PreOrderForOuterRsp> preOrderForOuter(@RequestParam(defaultValue = "") String regName,
			@RequestParam(defaultValue = "") String contactNumber, @RequestParam(defaultValue = "") String psptId,
			@RequestParam(defaultValue = "") String address, @RequestParam(defaultValue = "") String city,
			@RequestParam(defaultValue = "") String county, @RequestParam(defaultValue = "") String discntCode,
			@RequestParam(defaultValue = "") String paramCode,
			@RequestParam(defaultValue = "") String outerSerialNumber,
			@RequestParam(defaultValue = "") String createTime, @RequestParam(defaultValue = "") String staffId,
			@RequestParam(defaultValue = "") String serialNumber) {
		try {
			Map<String, Object> map = new HashMap<>();
			map.put("regName", regName);
			map.put("contactNumber", contactNumber);
			map.put("psptId", psptId);
			map.put("address", address);
			map.put("city", city);
			map.put("county", county);
			map.put("discntCode", discntCode);
			map.put("paramCode", paramCode);
			map.put("outerSerialNumber", outerSerialNumber);
			map.put("createTime", createTime);
			map.put("staffId", staffId);
			map.put("serialNumber", serialNumber);

			return ApiRestResponse.success(CommonConstants.STATUS_OK_MESSAGE, rechargeService.preOrderForOuter(map));
		} catch (BaseException e) {
			return ApiRestResponse.fail(e.getStatus(), e.getMessage(), null);
		} catch (Exception e) {
			log.error(CommonConstants.STATUS_ERROR_MESSAGE + "{}", e.getMessage(), e);
			return ApiRestResponse.fail(CommonConstants.STATUS_ERROR_MESSAGE, null);
		}
	}

	// 4.14互联网渠道客户证件号码校验
	@ResponseBody
	@RequestMapping(value = "/checkIdandCarinfo", method = RequestMethod.GET)
	public ApiRestResponse<Boolean> checkIdandCarinfo(@RequestParam(defaultValue = "") String psptId,
			@RequestParam(defaultValue = "") String custName) {
		try {
			Map<String, Object> map = new HashMap<>();
			map.put("psptId", psptId);
			map.put("custName", custName);
			return ApiRestResponse.success(CommonConstants.STATUS_OK_MESSAGE, rechargeService.checkIdandCarinfo(map));
		} catch (BaseException e) {
			return ApiRestResponse.fail(e.getStatus(), e.getMessage(), null);
		} catch (Exception e) {
			log.error(CommonConstants.STATUS_ERROR_MESSAGE + "{}", e.getMessage(), e);
			return ApiRestResponse.fail(CommonConstants.STATUS_ERROR_MESSAGE, null);
		}
	}

	// 4.16互联网渠道选号
	@ResponseBody
	@RequestMapping(value = "/queryOutNumInfo", method = RequestMethod.GET)
	public ApiRestResponse<QueryOutNumInfoRsp> queryOutNumInfo(@RequestParam(defaultValue = "") String snEparchyCode,
			@RequestParam(defaultValue = "") String snCityCode) {
		try {
			Map<String, Object> map = new HashMap<>();
			map.put("snEparchyCode", snEparchyCode);
			map.put("snCityCode", snCityCode);

			return ApiRestResponse.success(CommonConstants.STATUS_OK_MESSAGE, rechargeService.queryOutNumInfo(map));
		} catch (BaseException e) {
			return ApiRestResponse.fail(e.getStatus(), e.getMessage(), null);
		} catch (Exception e) {
			log.error(CommonConstants.STATUS_ERROR_MESSAGE + "{}", e.getMessage(), e);
			return ApiRestResponse.fail(CommonConstants.STATUS_ERROR_MESSAGE, null);
		}
	}

	// 4.17 互联网渠道号码选占接口
	@ResponseBody
	@RequestMapping(value = "/selTempOccupyResOut", method = RequestMethod.GET)
	public ApiRestResponse<SelTempOccupyResOutRsp> selTempOccupyResOut(
			@RequestParam(defaultValue = "") String occupyTypeCode, @RequestParam(defaultValue = "") String resNo,
			@RequestParam(defaultValue = "") String resTypeCode) {
		try {
			Map<String, Object> map = new HashMap<>();
			map.put("occupyTypeCode", occupyTypeCode);
			map.put("resNo", resNo);
			map.put("resTypeCode", resTypeCode);

			return ApiRestResponse.success(CommonConstants.STATUS_OK_MESSAGE, rechargeService.selTempOccupyResOut(map));
		} catch (BaseException e) {
			return ApiRestResponse.fail(e.getStatus(), e.getMessage(), null);
		} catch (Exception e) {
			log.error(CommonConstants.STATUS_ERROR_MESSAGE + "{}", e.getMessage(), e);
			return ApiRestResponse.fail(CommonConstants.STATUS_ERROR_MESSAGE, null);
		}
	}

	// 全网信用购机活动列表查询接口
	@ResponseBody
	@RequestMapping(value = "/wholeNetListOut", method = RequestMethod.GET)
	public ApiRestResponse<Object> wholeNetListOut(@RequestParam(defaultValue = "") String serialNumber,
			@RequestParam(defaultValue = "") String productTypeCode) {
		try {
			Map<String, Object> map = new HashMap<>();
			map.put("serialNumber", serialNumber);
			map.put("productTypeCode", productTypeCode);
			return ApiRestResponse.success(CommonConstants.STATUS_OK_MESSAGE, rechargeService.wholeNetListOut(map));
		} catch (BaseException e) {
			return ApiRestResponse.fail(e.getStatus(), e.getMessage(), null);
		} catch (Exception e) {
			log.error(CommonConstants.STATUS_ERROR_MESSAGE + "{}", e.getMessage(), e);
			return ApiRestResponse.fail(CommonConstants.STATUS_ERROR_MESSAGE, null);
		}
	}

	// 全网信用购机活动详情查询接口
	@ResponseBody
	@RequestMapping(value = "/wholeNetDescOut", method = RequestMethod.GET)
	public ApiRestResponse<Object> wholeNetDescOut(@RequestParam(defaultValue = "") String serialNumber,
			@RequestParam(defaultValue = "") String productTypeCode,
			@RequestParam(defaultValue = "") String productId) {
		try {
			Map<String, Object> map = new HashMap<>();
			map.put("serialNumber", serialNumber);
			map.put("productTypeCode", productTypeCode);
			map.put("productId", productId);

			return ApiRestResponse.success(CommonConstants.STATUS_OK_MESSAGE, rechargeService.wholeNetDescOut(map));
		} catch (BaseException e) {
			return ApiRestResponse.fail(e.getStatus(), e.getMessage(), null);
		} catch (Exception e) {
			log.error(CommonConstants.STATUS_ERROR_MESSAGE + "{}", e.getMessage(), e);
			return ApiRestResponse.fail(CommonConstants.STATUS_ERROR_MESSAGE, null);
		}
	}

	// 全网信用购机活动终端串号校验接口
	@ResponseBody
	@RequestMapping(value = "/chkWholeNetTerminalOut", method = RequestMethod.GET)
	public ApiRestResponse<Object> chkWholeNetTerminalOut(@RequestParam(defaultValue = "") String serialNumber,
			@RequestParam(defaultValue = "") String productTypeCode, @RequestParam(defaultValue = "") String productId,
			@RequestParam(defaultValue = "") String resType, @RequestParam(defaultValue = "") String resCode

	) {
		try {
			Map<String, Object> map = new HashMap<>();
			map.put("serialNumber", serialNumber);
			map.put("productTypeCode", productTypeCode);
			map.put("productId", productId);
			map.put("resType", resType);
			map.put("resCode", resCode);

			return ApiRestResponse.success(CommonConstants.STATUS_OK_MESSAGE,
					rechargeService.chkWholeNetTerminalOut(map));
		} catch (BaseException e) {
			return ApiRestResponse.fail(e.getStatus(), e.getMessage(), null);
		} catch (Exception e) {
			log.error(CommonConstants.STATUS_ERROR_MESSAGE + "{}", e.getMessage(), e);
			return ApiRestResponse.fail(CommonConstants.STATUS_ERROR_MESSAGE, null);
		}
	}

	// 全网信用购机活动受理接口
	@ResponseBody
	@RequestMapping(value = "/orderWholeNetTradeOut", method = RequestMethod.GET)
	public ApiRestResponse<Object> orderWholeNetTradeOut(@RequestParam(defaultValue = "") String serialNumber,
			@RequestParam(defaultValue = "") String productTypeCode, @RequestParam(defaultValue = "") String productId,
			@RequestParam(defaultValue = "") String mainResCode,
			@RequestParam(defaultValue = "") String mainDeviceModelCode,
			@RequestParam(defaultValue = "") String mainDeviceModel,
			@RequestParam(defaultValue = "") String mainBindMember, @RequestParam(defaultValue = "") String mainResType,
			@RequestParam(defaultValue = "") String voiceProductId,
			@RequestParam(defaultValue = "") String voiceDiscCode, @RequestParam(defaultValue = "") String preType,
			@RequestParam(defaultValue = "") String smsCode) {
		try {
			Map<String, Object> map = new HashMap<>();
			map.put("serialNumber", serialNumber);
			map.put("productTypeCode", productTypeCode);
			map.put("productId", productId);
			map.put("mainResCode", mainResCode);
			map.put("mainDeviceModelCode", mainDeviceModelCode);
			map.put("mainDeviceModel", mainDeviceModel);
			map.put("mainBindMember", mainBindMember);
			map.put("mainResType", mainResType);
			map.put("voiceProductId", voiceProductId);
			map.put("voiceDiscCode", voiceDiscCode);
			map.put("preType", preType);
			map.put("smsCode", smsCode);

			return ApiRestResponse.success(CommonConstants.STATUS_OK_MESSAGE,
					rechargeService.orderWholeNetTradeOut(map));
		} catch (BaseException e) {
			return ApiRestResponse.fail(e.getStatus(), e.getMessage(), null);
		} catch (Exception e) {
			log.error(CommonConstants.STATUS_ERROR_MESSAGE + "{}", e.getMessage(), e);
			return ApiRestResponse.fail(CommonConstants.STATUS_ERROR_MESSAGE, null);
		}
	}

}
